/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * MainAdministratorViewImpl.java
 *
 * Created on 03/03/2010, 23:27:11
 */

package tpdisenio2009.mvp.display;

import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ActionListener;
import javax.swing.JOptionPane;
import tpdisenio2009.mvp.presenter.CloseTournamentDatePresenter;
import tpdisenio2009.mvp.presenter.ManageBanPeriodsPresenter;

/**
 *
 * @author DeuterioX
 */
public class MainAdministratorViewImpl extends javax.swing.JFrame implements MainAdministratorView {

    /** Creates new form MainAdministratorViewImpl */
    public MainAdministratorViewImpl() {
        initComponents();

        ManageBanPeriodsViewImpl manageBanPeriodsView = new ManageBanPeriodsViewImpl();
        ManageBanPeriodsPresenter manageBanPeriodsPresenter = new ManageBanPeriodsPresenter( manageBanPeriodsView );

        jTabbedPaneMainUser.add( "Períodos de Veda", manageBanPeriodsPresenter.getView().asWidget() );

        CloseTournamentDateViewImpl closeTournamentView = new CloseTournamentDateViewImpl();
        CloseTournamentDatePresenter closeTournamentPresenter = new CloseTournamentDatePresenter( closeTournamentView );

        jTabbedPaneMainUser.add( "Cerrar Fechas", closeTournamentPresenter.getView().asWidget() );

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        Dimension dim = this.getToolkit().getScreenSize();
        this.setLocation((dim.width - this.getWidth()) / 2,(dim.height - this.getHeight()) / 2);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTabbedPaneMainUser = new javax.swing.JTabbedPane();
        jButtonCloseSession = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(tpdisenio2009.Tpdisenio2009App.class).getContext().getResourceMap(MainAdministratorViewImpl.class);
        setTitle(resourceMap.getString("Form.title")); // NOI18N
        setName("Form"); // NOI18N

        jTabbedPaneMainUser.setName("jTabbedPaneMainUser"); // NOI18N

        jButtonCloseSession.setText(resourceMap.getString("jButtonCloseSession.text")); // NOI18N
        jButtonCloseSession.setName("jButtonCloseSession"); // NOI18N

        jLabel1.setFont(resourceMap.getFont("jLabel1.font")); // NOI18N
        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jTabbedPaneMainUser, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 780, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 585, Short.MAX_VALUE)
                        .addComponent(jButtonCloseSession)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(11, 11, 11)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButtonCloseSession)
                    .addComponent(jLabel1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTabbedPaneMainUser, javax.swing.GroupLayout.DEFAULT_SIZE, 453, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonCloseSession;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JTabbedPane jTabbedPaneMainUser;
    // End of variables declaration//GEN-END:variables

    public void addCloseSessionListener( ActionListener listener ) {
        jButtonCloseSession.addActionListener(listener);
    }

    public void removeCloseSessionListener( ActionListener listener ) {
        jButtonCloseSession.removeActionListener(listener);
    }

    public boolean showConfirmation( String notifiactionMessage ) {
        int confirm = JOptionPane.showConfirmDialog( this, notifiactionMessage, "Confirmación", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE );

        if (JOptionPane.YES_OPTION == confirm)
            return true;
        else
            return false;
    }

    public Component asWidget() {
        return this;
    }
}
